﻿@model IEnumerable<MinistryStandardPlatformWeb.Models.WarningInfo>
<div class="box verticalbox fillparentheight">
    <div class="fillparentheight" id="mileagedetailcontainer" style="overflow:auto;border-bottom: #95B8E7 1px solid;">
        <table class="tablelist" id="vehiclewarningdetail">
            <thead>
                <tr>
                    <th>车牌号</th>
                    <th>Sim卡号</th>
                    <th>所属单位</th>
                    <th>报警时间</th>
                    <th>报警类型</th>
                    <th>报警位置</th>
                    <th style="display:none;"></th>
                    <th style="display:none;"></th>
                </tr>
            </thead>
            <tbody>
                @{
                    foreach (var item in Model)
                    {
                    <tr id="@item.Sim">
                        <td>@item.VehicleId</td>
                        <td>@item.Sim</td>
                        <td>@item.ParentUnitName</td>
                        <td>@item.WarningTime</td>
                        <td>@item.WarningTypeName</td>
                        <td>@item.POI</td>
                        <td style="display:none;">@item.longitude</td>
                        <td style="display:none;">@item.latitude</td>
                    </tr>
                    }
                }
            </tbody>
        </table>
    </div>
    <div style="margin-top: 5px;">
        <div style="float: right; margin-right: 18px;">
            <input type="button" value="导出明细" id="exportStatistics" onclick="tableToExcel('车辆警报明细', 'vehiclewarningdetail');" />
        </div>
    </div>
</div>

<script>
    $(document).ready(function () {
        var len = $("#vehiclewarningdetail tbody tr").length;
        //alert(len);

        if (len > 0) {
            parsePoi(-1);
        }

        function parsePoi(startIndex) {
            //alert(startIndex);
            var longs = Array();
            var latis = Array();
            if (startIndex >= len) {
                return false;
            }

            var selector = "#vehiclewarningdetail tbody tr:lt(" + (startIndex + 11) + ")";
            if (startIndex != -1) {
                selector += (":gt(" + startIndex + ")");
            }
            $(selector).each(function (index, element) {
                longs[index] = $(this).children().eq(6).html();
                latis[index] = $(this).children().eq(7).html();
            });
            //alert($.toJSON(longs));

            $.ajax({
                type: "post",
                url: "/WarningDetail/GetPoi",
                data: {
                    "longList": longs,
                    "latiList": latis
                },
                traditional: true,
                success: function (data) {
                    if (data != null) {
                        //alert(data);
                        //var pois = $.parseJSON(data);

                        $(selector).each(function (index, element) {
                            $(this).children().eq(5).html(data[index]);
                        });
                    }
                }
            });
            setTimeout(function () {
                parsePoi(startIndex + 10);
            }, 500);

        }
    });
</script>
